package com.example.rbacmanage.service.app.impl;

import com.example.rbacmanage.entity.app.ManagementModel;
import com.example.rbacmanage.mapper.app.ManagementModelMapper;
import com.example.rbacmanage.service.app.ManagementModelService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class ManagementModelServiceImpl implements ManagementModelService {
    @Autowired
    private ManagementModelMapper managementModelMapper;
    @Override
    public void save(ManagementModel managementModel) {
        managementModel.setCreateTime(new Date());
        managementModelMapper.insert(managementModel);
    }

    @Override
    public void remove(Long[] ids) {
        for (Long id : ids) {
            managementModelMapper.del(id);
        }
    }

    @Override
    public void update(ManagementModel managementModel) {
        managementModelMapper.update(managementModel);
    }

    @Override
    public List<ManagementModel> getAll(ManagementModel managementModel) {
        return managementModelMapper.list(managementModel);
    }

    @Override
    public PageInfo<ManagementModel> getPage(ManagementModel managementModel) {
        return new PageInfo<>(getAll(managementModel));
    }

    @Override
    public ManagementModel getById(Long id) {
        return managementModelMapper.queryOneById(id);
    }

    @Override
    public Integer getCount(ManagementModel managementModel) {
        return managementModelMapper.count(managementModel);
    }
}
